﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using OFB.BLL.Context;
using OFB.BLL.ViewModel;
using OFB.Domain;

namespace OFB.BLL.Repository
{
    public class FeedbackAnswerDetailBLL : IFeedbackAnswerDetailBLL
    {
        private readonly FeedbackkContext context;

        public FeedbackAnswerDetailBLL()
        {
            context = new FeedbackkContext();
        }

        public ICollection<Criteria> CriteriaListAll(int fbDetailId)
        {
            return context.Criteria.Init("FeedbackDetailCriteria_ListAll",
                context.Criteria.BuildParameter("FbDetailId", DbType.Int32, fbDetailId))
                                                .MapCollection<Criteria>()
                                                .GetCollection();
        }

        public ICollection<FeedbackAnswerDetailViewModel> QuestionListAll(int fbDetailId, string criteriaName)
        {
            return context.FeedbackAnswerDetailViewModel.Init("FeedbackDetailQuestion_ListAll",
                context.FeedbackAnswerDetailViewModel.BuildParameter("FbDetailId", DbType.Int32, fbDetailId),
                context.FeedbackAnswerDetailViewModel.BuildParameter("CriteriaName", DbType.String, criteriaName))
                                                .MapCollection<FeedbackAnswerDetailViewModel>()
                                                .GetCollection();
        }
    }
}
